﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace FORUs
{
    public partial class Frm03_MainScreen : Form
    {
        public Frm03_MainScreen()
        {
            InitializeComponent();
        }

        private void quitterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void répertoireDeChansonsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fBrowser = new FolderBrowserDialog();
            fBrowser.ShowNewFolderButton = false;
            fBrowser.SelectedPath = Program.SongDirectory;
            if (fBrowser.ShowDialog() != DialogResult.OK)
                return;

            Program.SongDirectory = fBrowser.SelectedPath;
            Program.ConfigurationFile.WriteValue("SONGS", "DIRECTORY", Program.SongDirectory);
        }

        private void répertoireDesPlaylistsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fBrowser = new FolderBrowserDialog();
            fBrowser.ShowNewFolderButton = false;
            fBrowser.SelectedPath = Program.PlaylistDirectory;
            if (fBrowser.ShowDialog() != DialogResult.OK)
                return;

            Program.PlaylistDirectory = fBrowser.SelectedPath;
            Program.ConfigurationFile.WriteValue("PLAYLISTS", "DIRECTORY", Program.SongDirectory);
        }

        private void editerLesMorceauxToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Frm01_TracksWindow EditSongs = new Frm01_TracksWindow();
            EditSongs.ShowDialog();
        }

        private void ouvrirUnePlaylistToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog fDialog = new SaveFileDialog();
            fDialog.AddExtension = true;
            fDialog.DefaultExt = "upl";
            fDialog.Filter = "Ultrastar Playlist (*.upl)|*.upl";
            fDialog.CheckFileExists = false;
            fDialog.InitialDirectory = Program.PlaylistDirectory;
            if (fDialog.ShowDialog() != DialogResult.OK)
                return;

            UltrastarPlaylist uPlaylist = null;
            if (System.IO.File.Exists(fDialog.FileName))
                uPlaylist = UltrastarPlaylist.FromFile(fDialog.FileName);
            else
                uPlaylist = UltrastarPlaylist.CreateTo(fDialog.FileName, "Nouvelle Playlist");

            Frm02_EditPlaylist OpenPlaylist = new Frm02_EditPlaylist(uPlaylist);
            OpenPlaylist.ShowDialog();
        }
    }
}
